#include "object.h"
#include "objectwrapper.h"

#include <QtCore/QCoreApplication>
#include <QtCore/QDebug>
#include <QtGui/QAction>
#include <QtScript/QScriptEngine>
#include <QtScriptTools/QScriptEngineDebugger>

int main(int argc, char *argv[])
{
    QCoreApplication app(argc, argv);

    QScriptEngine myEngine;
    /*QScriptEngineDebugger debugger;
         debugger.attachTo(&myEngine);*/

    Object obj(10);
    ObjectWrapperBase* wrap = new ObjectWrapper(obj, myEngine);

    QScriptValue wrapValue = myEngine.newQObject(wrap);
    myEngine.globalObject().setProperty("s", wrapValue);

    //debugger.action(QScriptEngineDebugger::InterruptAction)->trigger();
    QScriptValue result = myEngine.evaluate("s.increment().increment();");
    if (myEngine.hasUncaughtException())
    {
        int line = myEngine.uncaughtExceptionLineNumber();
        //qDebug() << "uncaught exception at line" << line << ":" << result.toString();
    }

    delete wrap;

    return 0;
}
